// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod timeseries_insights_controller {
    use crate::Result;

    /// A builder for [TimeseriesInsightsController][crate::client::TimeseriesInsightsController].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_timeseriesinsights_v1::*;
    /// # use builder::timeseries_insights_controller::ClientBuilder;
    /// # use client::TimeseriesInsightsController;
    /// let builder : ClientBuilder = TimeseriesInsightsController::builder();
    /// let client = builder
    ///     .with_endpoint("https://timeseriesinsights.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::TimeseriesInsightsController;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = TimeseriesInsightsController;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::TimeseriesInsightsController] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [TimeseriesInsightsController::list_data_sets][crate::client::TimeseriesInsightsController::list_data_sets] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::ListDataSets;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListDataSets {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListDataSets(RequestBuilder<crate::model::ListDataSetsRequest>);

    impl ListDataSets {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListDataSetsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListDataSetsResponse> {
            (*self.0.stub)
                .list_data_sets(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListDataSetsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListDataSetsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListDataSetsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListDataSetsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListDataSetsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListDataSets {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TimeseriesInsightsController::create_data_set][crate::client::TimeseriesInsightsController::create_data_set] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::CreateDataSet;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateDataSet {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateDataSet(RequestBuilder<crate::model::CreateDataSetRequest>);

    impl CreateDataSet {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateDataSetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::DataSet> {
            (*self.0.stub)
                .create_data_set(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateDataSetRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [dataset][crate::model::CreateDataSetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::DataSet>,
        {
            self.0.request.dataset = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [dataset][crate::model::CreateDataSetRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_dataset<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::DataSet>,
        {
            self.0.request.dataset = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateDataSet {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TimeseriesInsightsController::delete_data_set][crate::client::TimeseriesInsightsController::delete_data_set] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::DeleteDataSet;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteDataSet {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteDataSet(RequestBuilder<crate::model::DeleteDataSetRequest>);

    impl DeleteDataSet {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteDataSetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_data_set(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteDataSetRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteDataSet {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TimeseriesInsightsController::append_events][crate::client::TimeseriesInsightsController::append_events] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::AppendEvents;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> AppendEvents {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct AppendEvents(RequestBuilder<crate::model::AppendEventsRequest>);

    impl AppendEvents {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AppendEventsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AppendEventsResponse> {
            (*self.0.stub)
                .append_events(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [events][crate::model::AppendEventsRequest::events].
        pub fn set_events<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::Event>,
        {
            use std::iter::Iterator;
            self.0.request.events = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [dataset][crate::model::AppendEventsRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for AppendEvents {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TimeseriesInsightsController::query_data_set][crate::client::TimeseriesInsightsController::query_data_set] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::QueryDataSet;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> QueryDataSet {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct QueryDataSet(RequestBuilder<crate::model::QueryDataSetRequest>);

    impl QueryDataSet {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::QueryDataSetRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::QueryDataSetResponse> {
            (*self.0.stub)
                .query_data_set(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::QueryDataSetRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [detection_time][crate::model::QueryDataSetRequest::detection_time].
        ///
        /// This is a **required** field for requests.
        pub fn set_detection_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.detection_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [detection_time][crate::model::QueryDataSetRequest::detection_time].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_detection_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.detection_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [num_returned_slices][crate::model::QueryDataSetRequest::num_returned_slices].
        pub fn set_num_returned_slices<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<i32>,
        {
            self.0.request.num_returned_slices = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [num_returned_slices][crate::model::QueryDataSetRequest::num_returned_slices].
        pub fn set_or_clear_num_returned_slices<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<i32>,
        {
            self.0.request.num_returned_slices = v.map(|x| x.into());
            self
        }

        /// Sets the value of [slicing_params][crate::model::QueryDataSetRequest::slicing_params].
        pub fn set_slicing_params<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::SlicingParams>,
        {
            self.0.request.slicing_params = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [slicing_params][crate::model::QueryDataSetRequest::slicing_params].
        pub fn set_or_clear_slicing_params<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::SlicingParams>,
        {
            self.0.request.slicing_params = v.map(|x| x.into());
            self
        }

        /// Sets the value of [timeseries_params][crate::model::QueryDataSetRequest::timeseries_params].
        pub fn set_timeseries_params<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::TimeseriesParams>,
        {
            self.0.request.timeseries_params = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [timeseries_params][crate::model::QueryDataSetRequest::timeseries_params].
        pub fn set_or_clear_timeseries_params<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::TimeseriesParams>,
        {
            self.0.request.timeseries_params = v.map(|x| x.into());
            self
        }

        /// Sets the value of [forecast_params][crate::model::QueryDataSetRequest::forecast_params].
        pub fn set_forecast_params<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ForecastParams>,
        {
            self.0.request.forecast_params = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [forecast_params][crate::model::QueryDataSetRequest::forecast_params].
        pub fn set_or_clear_forecast_params<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ForecastParams>,
        {
            self.0.request.forecast_params = v.map(|x| x.into());
            self
        }

        /// Sets the value of [return_timeseries][crate::model::QueryDataSetRequest::return_timeseries].
        pub fn set_return_timeseries<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_timeseries = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for QueryDataSet {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TimeseriesInsightsController::evaluate_slice][crate::client::TimeseriesInsightsController::evaluate_slice] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::EvaluateSlice;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> EvaluateSlice {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct EvaluateSlice(RequestBuilder<crate::model::EvaluateSliceRequest>);

    impl EvaluateSlice {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::EvaluateSliceRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::EvaluatedSlice> {
            (*self.0.stub)
                .evaluate_slice(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [dataset][crate::model::EvaluateSliceRequest::dataset].
        ///
        /// This is a **required** field for requests.
        pub fn set_dataset<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset = v.into();
            self
        }

        /// Sets the value of [pinned_dimensions][crate::model::EvaluateSliceRequest::pinned_dimensions].
        ///
        /// This is a **required** field for requests.
        pub fn set_pinned_dimensions<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::PinnedDimension>,
        {
            use std::iter::Iterator;
            self.0.request.pinned_dimensions = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [detection_time][crate::model::EvaluateSliceRequest::detection_time].
        ///
        /// This is a **required** field for requests.
        pub fn set_detection_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.detection_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [detection_time][crate::model::EvaluateSliceRequest::detection_time].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_detection_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.detection_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [timeseries_params][crate::model::EvaluateSliceRequest::timeseries_params].
        pub fn set_timeseries_params<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::TimeseriesParams>,
        {
            self.0.request.timeseries_params = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [timeseries_params][crate::model::EvaluateSliceRequest::timeseries_params].
        pub fn set_or_clear_timeseries_params<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::TimeseriesParams>,
        {
            self.0.request.timeseries_params = v.map(|x| x.into());
            self
        }

        /// Sets the value of [forecast_params][crate::model::EvaluateSliceRequest::forecast_params].
        pub fn set_forecast_params<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ForecastParams>,
        {
            self.0.request.forecast_params = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [forecast_params][crate::model::EvaluateSliceRequest::forecast_params].
        pub fn set_or_clear_forecast_params<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ForecastParams>,
        {
            self.0.request.forecast_params = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for EvaluateSlice {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TimeseriesInsightsController::evaluate_timeseries][crate::client::TimeseriesInsightsController::evaluate_timeseries] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_timeseriesinsights_v1::builder;
    /// use builder::timeseries_insights_controller::EvaluateTimeseries;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> EvaluateTimeseries {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct EvaluateTimeseries(RequestBuilder<crate::model::EvaluateTimeseriesRequest>);

    impl EvaluateTimeseries {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TimeseriesInsightsController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::EvaluateTimeseriesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::EvaluatedSlice> {
            (*self.0.stub)
                .evaluate_timeseries(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::EvaluateTimeseriesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [timeseries][crate::model::EvaluateTimeseriesRequest::timeseries].
        pub fn set_timeseries<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Timeseries>,
        {
            self.0.request.timeseries = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [timeseries][crate::model::EvaluateTimeseriesRequest::timeseries].
        pub fn set_or_clear_timeseries<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Timeseries>,
        {
            self.0.request.timeseries = v.map(|x| x.into());
            self
        }

        /// Sets the value of [granularity][crate::model::EvaluateTimeseriesRequest::granularity].
        pub fn set_granularity<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.granularity = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [granularity][crate::model::EvaluateTimeseriesRequest::granularity].
        pub fn set_or_clear_granularity<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.granularity = v.map(|x| x.into());
            self
        }

        /// Sets the value of [forecast_params][crate::model::EvaluateTimeseriesRequest::forecast_params].
        pub fn set_forecast_params<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ForecastParams>,
        {
            self.0.request.forecast_params = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [forecast_params][crate::model::EvaluateTimeseriesRequest::forecast_params].
        pub fn set_or_clear_forecast_params<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ForecastParams>,
        {
            self.0.request.forecast_params = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for EvaluateTimeseries {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
